package cn.fantasy.task;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author ET
 * @description TODO
 * @date 2023/4/26 14:56
 * @Version V1.0
 */
public class Task1 {
    public static void main(String[] args) {
//        List<String> strings = Arrays.asList("a", "bb", "ccc");
//
//        List<Integer> lengths = strings.stream()
//                .map(s -> Optional.ofNullable(s).map(String::length))
//                .flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
//                .collect(Collectors.toList());
//        Iterator<Integer> iterator = lengths.iterator();
//        while (iterator.hasNext()) {
//            Integer next = iterator.next();
//            iterator.remove();
//
//            System.out.println(next);
//        }
        List<String> list = new ArrayList<>(Arrays.asList("foo", "bar", "baz"));
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
            String s = it.next();
            if (s.equals("bar")) {
                it.remove();
            }
        }

        list.removeIf(s -> s.equals("bar"));
        System.out.println(list);





    }


}
